#ifndef __BUFFERS_HPP__
#define __BUFFERS_HPP__
#include <glad/glad.h>

//VBO
class VertexBuffer
{
public:
    VertexBuffer()
    {
        glGenBuffers(1, &id);
    }
    ~VertexBuffer()
    {
        //if(!id) this->Delete();
    }
    GLuint getID() { return id;}
    void bind() {glBindBuffer(GL_ARRAY_BUFFER, id);}
    void unbind() {glBindBuffer(GL_ARRAY_BUFFER, 0);}
    void Delete() { glDeleteBuffers(1, &id); id = 0;}
    void setData(GLsizeiptr size, const void *data, GLenum usage)
    {
        this->bind();
        glBufferData(GL_ARRAY_BUFFER, size, data, usage);
        this->unbind();
    }
private:
    GLuint id;
};

//EBO
class IndexBuffer
{
public:
    IndexBuffer()
    {
        glGenBuffers(1, &id);
    }
    ~IndexBuffer()
    {
        //if(!id) this->Delete();
    }
    GLuint getID() { return id;}
    void bind() {glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, id);}
    void unbind() {glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);}
    void Delete() {glDeleteBuffers(1, &id); id = 0;}
    void setData(GLsizeiptr size, const void *data, GLenum usage)
    {
        this->bind();
        glBufferData(GL_ELEMENT_ARRAY_BUFFER, size, data, usage);
        this->unbind();
    }
private:
    GLuint id;
};
#endif